package com.juneyaoair.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

/**
 * @author 袁闻锴
 * @date 2020/10/31 10:27
 */
@ResponseBody
@Controller
public class TestController {

    // @Value("${server.port}") 获取application配置文件中的值
    @Value("${server.port}")
    private String port;

    @GetMapping("test")
    public String test(String name) {
        return "我是生产者，端口是：" + port + ",内容是：" + name ;
    }


    /**
     * @RequestBody 获取请求体中的参数 json
     */
    @PostMapping("testPost")
    public String testPost(@RequestBody Map map){
        System.out.println(map);
        return "testPost+"+port;
    }

}
